package dcedit.factories;

// Import Java/SDK Classes
import java.awt.*;

import javax.swing.*;

// Import Application Classes
import dcedit.util.*;
import dcedit.DCEdit;

/** BtnFactory class */
public class BtnFactory {
   /** Private Constructor */
   private BtnFactory() {} // constructor

   /** createAddBtn method */
   public static DynamicOmniImage createAddBtn() {
      final DynamicOmniImage BTN = new DynamicOmniImage(
         DCEdit.class.getResource(Constants.ADD_IMAGE),
         DCEdit.class.getResource(Constants.ADD_IMAGE_HOVER),
         DCEdit.class.getResource(Constants.ADD_IMAGE_CLICK)
      );
      BTN.setBorder(BorderFactory.createLineBorder(Colors.getAppBackgroundColor()));
      BTN.addMouseListener(ActionFactory.createAddTabListener());
      BTN.setToolTipText(Constants.ADD_NEW_PAGE_TOOLTIP_TEXT);
      return BTN;
   } // END createAddBtn

   /** createOpenBtn method */
   public static DynamicOmniImage createOpenBtn() {
      final DynamicOmniImage BTN = new DynamicOmniImage(
         DCEdit.class.getResource(Constants.FOLDER_IMAGE),
         DCEdit.class.getResource(Constants.FOLDER_IMAGE_HOVER),
         DCEdit.class.getResource(Constants.FOLDER_IMAGE_CLICK)
      );
      BTN.setBorder(BorderFactory.createLineBorder(Colors.getAppBackgroundColor()));
      BTN.addMouseListener(ActionFactory.createOpenTabListener());
      BTN.setToolTipText(Constants.OPEN_FILE_TOOLTIP_TEXT);
      return BTN;
   } // END createOpenBtn

   /** createSaveBtn method */
   public static DynamicOmniImage createSaveBtn() {
      final DynamicOmniImage BTN = new DynamicOmniImage(
         DCEdit.class.getResource(Constants.SAVE_IMAGE),
         DCEdit.class.getResource(Constants.SAVE_IMAGE_HOVER),
         DCEdit.class.getResource(Constants.SAVE_IMAGE_CLICK)
      );
      BTN.setBorder(BorderFactory.createLineBorder(Colors.getAppBackgroundColor()));
      BTN.addMouseListener(ActionFactory.createSaveTabListener());
      BTN.setToolTipText(Constants.SAVE_CURRENT_PAGE_TOOLTIP_TEXT);
      return BTN;
   } // END createSaveBtn

   /** createDeleteBtn method */
   public static DynamicOmniImage createDeleteBtn() {
      final DynamicOmniImage BTN = new DynamicOmniImage(
         DCEdit.class.getResource(Constants.CANCEL_IMAGE),
         DCEdit.class.getResource(Constants.CANCEL_IMAGE_HOVER),
         DCEdit.class.getResource(Constants.CANCEL_IMAGE_CLICK)
      );
      BTN.setBorder(BorderFactory.createLineBorder(Colors.getAppBackgroundColor()));
      BTN.addMouseListener(ActionFactory.createDeleteTabListener());
      BTN.setToolTipText(Constants.DELETE_CURRENT_PAGE_TOOLTIP_TEXT);
      return BTN;
   } // END createDeleteBtn

   /** createBoldBtn method */
   public static JToggleButton createBoldBtn() {
      final Insets BOLD_BTN_PAD = new Insets(0, 0, 0, 0);
      final Dimension BOLD_BTN_SIZE = new Dimension(30, 20);

      Constants.BOLD_BTN.setMargin(BOLD_BTN_PAD);
      Util.setComponentSizes(Constants.BOLD_BTN, BOLD_BTN_SIZE, true, true);
      Constants.BOLD_BTN.setFont(Constants.BOLD_BTN.getFont().deriveFont(Font.BOLD));

      Constants.BOLD_BTN.setToolTipText(Constants.BOLD_TOOLTIP_TEXT);

      if(Constants.BOLD_BTN.getActionListeners().length == 0) {
         Constants.BOLD_BTN.addActionListener(ActionFactory.createTabPaneFontActionListener());
      } // END if

      return Constants.BOLD_BTN;
   } // END createBoldBtn

   /** createItalicBtn method */
   public static JToggleButton createItalicBtn() {
      final Insets ITALIC_BTN_PAD = new Insets(0, 0, 0, 0);
      final Dimension ITALIC_BTN_SIZE = new Dimension(30, 20);

      Constants.ITALIC_BTN.setMargin(ITALIC_BTN_PAD);
      Util.setComponentSizes(Constants.ITALIC_BTN, ITALIC_BTN_SIZE, true, true);
      Constants.ITALIC_BTN.setFont(Constants.ITALIC_BTN.getFont().deriveFont(Font.ITALIC));

      Constants.ITALIC_BTN.setToolTipText(Constants.ITALIC_TOOLTIP_TEXT);

      if(Constants.ITALIC_BTN.getActionListeners().length == 0) {
         Constants.ITALIC_BTN.addActionListener(ActionFactory.createTabPaneFontActionListener());
      } // END if

      return Constants.ITALIC_BTN;
   } // END createItalicBtn

   /** createAutoIndentBtn method */
   public static JToggleButton createAutoIndentBtn() {
      final Insets AUTO_INDENT_BTN_PAD = new Insets(0, 0, 0, 0);
      final Dimension AUTO_INDENT_BTN_SIZE = new Dimension(30, 20);

      Constants.AUTO_INDENT_BTN.setMargin(AUTO_INDENT_BTN_PAD);
      Util.setComponentSizes(Constants.AUTO_INDENT_BTN, AUTO_INDENT_BTN_SIZE, true, true);

      Constants.AUTO_INDENT_BTN.setToolTipText(Constants.AUTO_INDENT_TOOLTIP_TEXT);

      if(Constants.AUTO_INDENT_BTN.getActionListeners().length == 0) {
         Constants.AUTO_INDENT_BTN.addActionListener(ActionFactory.createAutoIndentActionListener());
      } // END if

      return Constants.AUTO_INDENT_BTN;
   } // END createAutoIndentBtn

   /** createFontColorBtn method */
   public static JButton createFontColorBtn() {
      final Insets FONT_COLOR_BTN_PAD = new Insets(0, 0, 0, 0);
      final Dimension FONT_COLOR_BTN_SIZE = new Dimension(85, 20);

      Constants.FONT_COLOR_BTN.setMargin(FONT_COLOR_BTN_PAD);
      Util.setComponentSizes(Constants.FONT_COLOR_BTN, FONT_COLOR_BTN_SIZE, true, true);

      Constants.FONT_COLOR_BTN.setToolTipText(Constants.FONT_COLOR_TOOLTIP_TEXT);

      if(Constants.FONT_COLOR_BTN.getActionListeners().length == 0) {
         Constants.FONT_COLOR_BTN.addActionListener(ActionFactory.createTabFontColorActionListener());
      } // END if

      Constants.FONT_COLOR_BTN.setBackground(Colors.getTabForegroundColor());

      return Constants.FONT_COLOR_BTN;
   } // END createFontColorBtn

   /** createBackgroundColorBtn method */
   public static JButton createBackgroundColorBtn() {
      final Insets BACKGROUND_COLOR_BTN_PAD = new Insets(0, 0, 0, 0);
      final Dimension BACKGROUND_COLOR_BTN_SIZE = new Dimension(85, 20);

      Constants.BACKGROUND_COLOR_BTN.setMargin(BACKGROUND_COLOR_BTN_PAD);
      Util.setComponentSizes(Constants.BACKGROUND_COLOR_BTN, BACKGROUND_COLOR_BTN_SIZE, true, true);

      Constants.BACKGROUND_COLOR_BTN.setToolTipText(Constants.BACKGROUND_COLOR_TOOLTIP_TEXT);

      if(Constants.BACKGROUND_COLOR_BTN.getActionListeners().length == 0) {
         Constants.BACKGROUND_COLOR_BTN.addActionListener(ActionFactory.createTabBackgroundColorActionListener());
      } // END if

      Constants.BACKGROUND_COLOR_BTN.setBackground(Colors.getTabBackgroundColor());

      return Constants.BACKGROUND_COLOR_BTN;
   } // END createBackgroundColorBtn

   /** createHighlightColorBtn method */
   public static JButton createHighlightColorBtn() {
      final Insets BACKGROUND_COLOR_BTN_PAD = new Insets(0, 0, 0, 0);
      final Dimension BACKGROUND_COLOR_BTN_SIZE = new Dimension(85, 20);

      Constants.HIGHLIGHT_COLOR_BTN.setMargin(BACKGROUND_COLOR_BTN_PAD);
      Util.setComponentSizes(Constants.HIGHLIGHT_COLOR_BTN, BACKGROUND_COLOR_BTN_SIZE, true, true);

      Constants.HIGHLIGHT_COLOR_BTN.setToolTipText(Constants.BACKGROUND_COLOR_TOOLTIP_TEXT);

      if(Constants.HIGHLIGHT_COLOR_BTN.getActionListeners().length == 0) {
         Constants.HIGHLIGHT_COLOR_BTN.addActionListener(ActionFactory.createTabHighlightColorActionListener());
      } // END if

      Constants.HIGHLIGHT_COLOR_BTN.setBackground(Colors.getTabHighlightColor());

      return Constants.HIGHLIGHT_COLOR_BTN;
   } // END createHighlightColorBtn

   /** createRollDiceBtn method */
   public static JButton createRollDiceBtn() {
      final JButton BTN = new JButton(Constants.ROLL_DICE_TEXT);

      final Insets BTN_PAD = new Insets(0, 0, 0, 0);
      final Dimension BTN_SIZE = new Dimension(75, 20);

      BTN.setMargin(BTN_PAD);
      Util.setComponentSizes(BTN, BTN_SIZE, true, true);

      BTN.setToolTipText(Constants.ROLL_DICE_TOOLTIP_TEXT);

      BTN.addActionListener(ActionFactory.createRollDiceActionListener());

      return BTN;
   } // END createRollDiceBtn

   /** createResetDiceBtn method */
   public static JButton createResetDiceBtn() {
      final JButton BTN = new JButton(Constants.RESET_DICE_TEXT);

      final Insets BTN_PAD = new Insets(0, 0, 0, 0);
      final Dimension BTN_SIZE = new Dimension(75, 20);

      BTN.setMargin(BTN_PAD);
      Util.setComponentSizes(BTN, BTN_SIZE, true, true);

      BTN.setToolTipText(Constants.RESET_DICE_TOOLTIP_TEXT);

      BTN.addActionListener(ActionFactory.createResetDiceActionListener());

      return BTN;
   } // END createResetDiceBtn

   /** createCloseDiceDialogBtn method */
   public static JButton createCloseDiceDialogBtn(final JDialog DIALOG) {
      final JButton BTN = new JButton(Constants.CLOSE_DICE_DIALOG_TEXT);

      final Insets BTN_PAD = new Insets(0, 0, 0, 0);
      final Dimension BTN_SIZE = new Dimension(75, 20);

      BTN.setMargin(BTN_PAD);
      Util.setComponentSizes(BTN, BTN_SIZE, true, true);

      BTN.setToolTipText(Constants.CLOSE_DICE_DIALOG_TOOLTIP_TEXT);

      BTN.addActionListener(ActionFactory.createCloseDialogActionListener(DIALOG));

      return BTN;
   } // END createCloseDiceDialogBtn

   /** createRollDiceModBtn method */
   public static JButton createRollDiceModBtn() {
      final JButton BTN = new JButton(Constants.ROLL_DICE_TEXT);

      final Insets BTN_PAD = new Insets(0, 0, 0, 0);
      final Dimension BTN_SIZE = new Dimension(75, 20);

      BTN.setMargin(BTN_PAD);
      Util.setComponentSizes(BTN, BTN_SIZE, true, true);

      BTN.setToolTipText(Constants.ROLL_DICE_TOOLTIP_TEXT);

      BTN.addActionListener(ActionFactory.createRollDiceModActionListener());

      return BTN;
   } // END createRollDiceModBtn

   /** createResetDiceBtn method */
   public static JButton createResetDiceModBtn() {
      final JButton BTN = new JButton(Constants.RESET_DICE_TEXT);

      final Insets BTN_PAD = new Insets(0, 0, 0, 0);
      final Dimension BTN_SIZE = new Dimension(75, 20);

      BTN.setMargin(BTN_PAD);
      Util.setComponentSizes(BTN, BTN_SIZE, true, true);

      BTN.setToolTipText(Constants.RESET_DICE_TOOLTIP_TEXT);

      BTN.addActionListener(ActionFactory.createResetDiceModActionListener());

      return BTN;
   } // END createResetDiceModBtn

   /** createCloseDiceModDialogBtn method */
   public static JButton createCloseDiceModDialogBtn(final JDialog DIALOG) {
      final JButton BTN = new JButton(Constants.CLOSE_DICE_DIALOG_TEXT);

      final Insets BTN_PAD = new Insets(0, 0, 0, 0);
      final Dimension BTN_SIZE = new Dimension(75, 20);

      BTN.setMargin(BTN_PAD);
      Util.setComponentSizes(BTN, BTN_SIZE, true, true);

      BTN.setToolTipText(Constants.CLOSE_DICE_DIALOG_TOOLTIP_TEXT);

      BTN.addActionListener(ActionFactory.createCloseDialogActionListener(DIALOG));

      return BTN;
   } // END createCloseDiceModDialogBtn

   /** createTranslateDialogBtn method */
   public static JButton createTranslateDialogBtn(final JDialog DIALOG,final String TEMPLATE_TEXT,final boolean NEW_TAB) {
      final JButton BTN = new JButton(Constants.TRANSLATE_DIALOG_TEXT);

      final Insets BTN_PAD = new Insets(0, 0, 0, 0);
      final Dimension BTN_SIZE = new Dimension(75, 20);

      BTN.setMargin(BTN_PAD);
      Util.setComponentSizes(BTN, BTN_SIZE, true, true);

      BTN.setToolTipText(Constants.TRANSLATE_DIALOG_TOOLTIP_TEXT);

      BTN.addActionListener(ActionFactory.createTranslateDialogActionListener(DIALOG,TEMPLATE_TEXT,NEW_TAB));

      return BTN;
   } // END createTranslateDialogBtn

   /** createCancelTranslateDialogBtn method */
   public static JButton createCancelTranslateDialogBtn(final JDialog DIALOG) {
      final JButton BTN = new JButton(Constants.CANCEL_TEXT);

      final Insets BTN_PAD = new Insets(0, 0, 0, 0);
      final Dimension BTN_SIZE = new Dimension(75, 20);

      BTN.setMargin(BTN_PAD);
      Util.setComponentSizes(BTN, BTN_SIZE, true, true);

      BTN.setToolTipText(Constants.CANCEL_TRANSLATE_DIALOG_TOOLTIP_TEXT);

      BTN.addActionListener(ActionFactory.createCloseDialogActionListener(DIALOG));

      return BTN;
   } // END createCancelTranslateDialogBtn

   /** createGenStatsDialogBtn method */
   public static JButton createGenStatsDialogBtn() {
      final JButton BTN = new JButton(Constants.GEN_STATS_DIALOG_TEXT);

      final Insets BTN_PAD = new Insets(0, 0, 0, 0);
      final Dimension BTN_SIZE = new Dimension(75, 20);

      BTN.setMargin(BTN_PAD);
      Util.setComponentSizes(BTN, BTN_SIZE, true, true);

      BTN.setToolTipText(Constants.GEN_STATS_DIALOG_TOOLTIP_TEXT);

      BTN.addActionListener(ActionFactory.createGenStatsDialogActionListener());

      return BTN;
   } // END createGenStatsDialogBtn

   /** createCharacterGenLoadCancelBtn method */
   public static JButton createCharacterGenLoadCancelBtn(final JDialog DIALOG) {
      final JButton BTN = new JButton(Constants.CANCEL_TEXT);

      final Insets BTN_PAD = new Insets(0, 0, 0, 0);
      final Dimension BTN_SIZE = new Dimension(75, 20);

      BTN.setMargin(BTN_PAD);
      Util.setComponentSizes(BTN, BTN_SIZE, true, true);

      BTN.setToolTipText(Constants.CANCEL_CHARACTER_GEN_LOAD_DIALOG_TOOLTIP_TEXT);

      BTN.addActionListener(ActionFactory.createCloseDialogActionListener(DIALOG));

      return BTN;
   } // END createCharacterGenLoadCancelBtn

   /** createCodecEncodeDecodeBtn method */
   public static JButton createCodecEncodeDecodeBtn() {
      final JButton BTN = new JButton(Constants.ENCODE_DECODE_TEXT);

      final Insets BTN_PAD = new Insets(0, 0, 0, 0);
      final Dimension BTN_SIZE = new Dimension(140, 20);

      BTN.setMargin(BTN_PAD);
      Util.setComponentSizes(BTN, BTN_SIZE, true, true);

      BTN.setToolTipText(Constants.ENCODE_DECODE_CODEC_DIALOG_TOOLTIP_TEXT);

      BTN.addActionListener(ActionFactory.createCodecEncodeDecodeActionListener());

      return BTN;
   } // END createCodecEncodeDecodeBtn

   /** createCodecCloseBtn method */
   public static JButton createCodecCloseBtn(final JDialog DIALOG) {
      final JButton BTN = new JButton(Constants.CANCEL_TEXT);

      final Insets BTN_PAD = new Insets(0, 0, 0, 0);
      final Dimension BTN_SIZE = new Dimension(140, 20);

      BTN.setMargin(BTN_PAD);
      Util.setComponentSizes(BTN, BTN_SIZE, true, true);

      BTN.setToolTipText(Constants.CANCEL_CODEC_DIALOG_TOOLTIP_TEXT);

      BTN.addActionListener(ActionFactory.createCloseDialogActionListener(DIALOG));

      return BTN;
   } // END createCodecCloseBtn

   /** createSearchPathBrowseBtn method */
   public static JButton createSearchPathBrowseBtn() {
      final JButton BTN = new JButton(Constants.BROWSE_TEXT);

      final Insets BTN_PAD = new Insets(0, 0, 0, 0);
      final Dimension BTN_SIZE = new Dimension(85, 20);

      BTN.setMargin(BTN_PAD);
      Util.setComponentSizes(BTN, BTN_SIZE, true, true);

      BTN.setToolTipText(Constants.BROWSE_TOOLTIP_TEXT);

      BTN.addActionListener(ActionFactory.createSearchPathBrowseActionListener());

      return BTN;
   } // END createSearchPathBrowseBtn

   /** createSearchSearchBtn method */
   public static JButton createSearchSearchBtn(final JDialog DIALOG) {
      final JButton BTN = new JButton(Constants.SEARCH_TEXT);

      final Insets BTN_PAD = new Insets(0, 0, 0, 0);
      final Dimension BTN_SIZE = new Dimension(85, 20);

      BTN.setMargin(BTN_PAD);
      Util.setComponentSizes(BTN, BTN_SIZE, true, true);

      BTN.setToolTipText(Constants.SEARCH_SEARCH_DIALOG_TOOLTIP_TEXT);

      BTN.addActionListener(ActionFactory.createSearchSearchActionListener(DIALOG, BTN));

      return BTN;
   } // END createSearchSearchBtn

   /** createSearchCloseBtn method */
   public static JButton createSearchCloseBtn(final JDialog DIALOG) {
      final JButton BTN = new JButton(Constants.CANCEL_TEXT);

      final Insets BTN_PAD = new Insets(0, 0, 0, 0);
      final Dimension BTN_SIZE = new Dimension(85, 20);

      BTN.setMargin(BTN_PAD);
      Util.setComponentSizes(BTN, BTN_SIZE, true, true);

      BTN.setToolTipText(Constants.CANCEL_SEARCH_DIALOG_TOOLTIP_TEXT);

      BTN.addActionListener(ActionFactory.createCloseDialogActionListener(DIALOG));

      return BTN;
   } // END createSearchCloseBtn

   /** createJavaDocSourceDirectoryBrowseBtn method */
   public static JButton createJavaDocSourceDirectoryBrowseBtn() {
      final JButton BTN = new JButton(Constants.BROWSE_TEXT);

      final Insets BTN_PAD = new Insets(0, 0, 0, 0);
      final Dimension BTN_SIZE = new Dimension(85, 20);

      BTN.setMargin(BTN_PAD);
      Util.setComponentSizes(BTN, BTN_SIZE, true, true);

      BTN.setToolTipText(Constants.BROWSE_TOOLTIP_TEXT);

      BTN.addActionListener(ActionFactory.createJavaDocSourceDirectoryActionListener());

      return BTN;
   } // END createJavaDocSourceDirectoryBrowseBtn

   /** createJavaDocDistinationDirectoryBrowseBtn method */
   public static JButton createJavaDocDistinationDirectoryBrowseBtn() {
      final JButton BTN = new JButton(Constants.BROWSE_TEXT);

      final Insets BTN_PAD = new Insets(0, 0, 0, 0);
      final Dimension BTN_SIZE = new Dimension(85, 20);

      BTN.setMargin(BTN_PAD);
      Util.setComponentSizes(BTN, BTN_SIZE, true, true);

      BTN.setToolTipText(Constants.BROWSE_TOOLTIP_TEXT);

      BTN.addActionListener(ActionFactory.createJavaDocDestinationDirectoryActionListener());

      return BTN;
   } // END createJavaDocDistinationDirectoryBrowseBtn

   /** createJavaDocGenBtn method */
   public static JButton createJavaDocGenBtn(final JTree STYLE_TREE) {
      final JButton BTN = new JButton(Constants.GEN_JAVA_DOC_TEXT);

      final Insets BTN_PAD = new Insets(0, 0, 0, 0);
      final Dimension BTN_SIZE = new Dimension(140, 20);

      BTN.setMargin(BTN_PAD);
      Util.setComponentSizes(BTN, BTN_SIZE, true, true);

      BTN.setToolTipText(Constants.GEN_JAVADOC_DIALOG_TOOLTIP_TEXT);

      BTN.addActionListener(ActionFactory.createGenerateJavaDocActionListener(STYLE_TREE));

      return BTN;
   } // END createJavaDocGenBtn

   /** createJavaDocCloseBtn method */
   public static JButton createJavaDocCloseBtn(final JDialog DIALOG) {
      final JButton BTN = new JButton(Constants.CANCEL_TEXT);

      final Insets BTN_PAD = new Insets(0, 0, 0, 0);
      final Dimension BTN_SIZE = new Dimension(140, 20);

      BTN.setMargin(BTN_PAD);
      Util.setComponentSizes(BTN, BTN_SIZE, true, true);

      BTN.setToolTipText(Constants.CANCEL_JAVADOC_DIALOG_TOOLTIP_TEXT);

      BTN.addActionListener(ActionFactory.createCloseDialogActionListener(DIALOG));

      return BTN;
   } // END createJavaDocCloseBtn
} // END class BtnFactory